package com.zzptc.myapp1112.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.zzptc.myapp1112.Bean.User;
import com.zzptc.myapp1112.R;

import java.lang.reflect.GenericArrayType;
import java.util.List;

public class ContactAdapter extends ArrayAdapter<User> {
    int resourceid;

    public ContactAdapter(@NonNull Context context, int resource, @NonNull List<User> objects) {
        super(context, resource, objects);
        this.resourceid = resource;

    }

    @Override
    public View getView(int position, View converView, ViewGroup parent) {
        View view = converView;
        if (view == null) {
            view = LayoutInflater.from(getContext()).inflate(resourceid, null);
        }
        ImageView contactimg = view.findViewById(R.id.contactimg);
        TextView contactname = view.findViewById(R.id.contactname);
        User user = getItem(position);
        contactimg.setImageResource(user.getUserimg());
        contactname.setText(user.getName());
        return view;
    }
}


